<template>
	<view class="mainSet">
		<u-navbar  title="设置"  :background="background" title-color="#FFF" back-icon-color="#fff"></u-navbar>
		<view class="mainSet-li" @click="versionClick">
			<view class="">
				版本号
			</view>
			<text>{{appversion}}</text>
		</view>
		<view class="mainSet-li" @click="deleteShow=true">
			<view class="">
				删除账号（谨慎操作）
			</view>
			<text></text>
		</view>
		<view class="mainSet-li" @click="sqFun">
			<view class="">
				授权管理
			</view>
			<text class="iconfont iconarrow_right"></text>
		</view>
		<view class="mainSet-li" @click="privacy">
			<view class="">
				隐私政策
			</view>
			<text class="iconfont iconarrow_right"></text>
		</view>
		<view class="mainSet-out" @click="outLoginShow=true">
			退出登录
		</view>
		<u-modal v-model="outLoginShow" content="请确认是否退出登录" :show-cancel-button="true" @confirm="outLoginConfirm"></u-modal>
		<u-modal v-model="deleteShow" content="请确认是否注销" :show-cancel-button="true" @confirm="deleteConfirm"></u-modal>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default{
		data(){
			return {
				background: {
					backgroundColor: '#00a1f1',
				},
				outLoginShow:false,
				deleteShow:false,
				userinfo:JSON.parse(uni.getStorageSync('userinfo')),
				platform:false,
				appversion:'1.0.0'
			}
		},
		onShow() {
			var that=this
			this.platform=uni.getStorageSync('platform')
			if(this.platform==true){
				plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
					that.appversion=widgetInfo.version
				});
			}
			
		},
		methods:{
			sqFun(){
				uni.navigateTo({
					url: '/pages/shouquan/shouquanAdmin/index'
				})
			},
			privacy() {
				uni.navigateTo({
					url: '/pages/business/privacy/privacyText?url='+'https://feishazoushi.cn/yszc/client_index.html'
				})
				
				
			},
			outLoginConfirm() {
				uni.showLoading({
				    title: '请求中',
					mask:true
				});
				uni.request({
					url: this.baseUrl + '/system/quit', 
					method: 'POST',
					dataType:'json',
					data:{
						PERTB005ID:this.userinfo.PERTB005ID
					},
					success: (res) => {
						console.log(res);
						if (res.data.code == 200) {
							uni.clearStorageSync()
							uni.reLaunch({
								url: '/pages/APPlogin/index'
							})
						}else{
							this.$refs.uToast.show({
								title: res.data.message,
								type: 'default',
								icon:false
							})
						}
						uni.hideLoading();
					},
					fail: (res) => {
						this.$refs.uToast.show({
							title: res.errMsg,
							type: 'default',
							icon:false
						})
						uni.hideLoading();
					}
				});
			},
			versionClick() {
				uni.navigateTo({
					url: '/pages/mainUpdate/index'
				})
			},
			deleteConfirm(){
				console.log(this.userinfo.PERTB005ID)
				uni.showLoading({
				    title: '请求中',
					mask:true
				});
				uni.request({
					url: this.baseUrl + '/per/pertb005/logout', 
					method: 'POST',
					dataType:'json',
					data:{
						PERTB005ID:this.userinfo.PERTB005ID
					},
					success: (res) => {
						console.log(res);
						if (res.data.code == 200) {
							this.$refs.uToast.show({
								title: '注销成功',
								type: 'default',
								icon:false
							})
							// uni.removeStorageSync('userinfo')
							uni.clearStorageSync()
							uni.reLaunch({
								url: '/pages/APPlogin/index'
							})
						}else{
							this.$refs.uToast.show({
								title: res.data.message,
								type: 'default',
								icon:false
							})
						}
						uni.hideLoading();
					},
					fail: (res) => {
						this.$refs.uToast.show({
							title: res.errMsg,
							type: 'default',
							icon:false
						})
						uni.hideLoading();
					}
				});
			}
		}
	}
</script>

<style scoped>
	.mainSet{
		min-height: 100vh;
		width: 100vw;
		background-color: #E3E3E3;
	}
	.mainSet-out{
		height: 90rpx;
		line-height: 90rpx;
		background-color: #FFF;
		font-size: 30rpx;
		color: #333;
		text-align: center;
		margin-top: 30rpx;
	}
	.mainSet-li{
		display: flex;
		justify-content: space-between;
		height: 90rpx;
		line-height: 90rpx;
		background-color: #FFF;
		font-size: 30rpx;
		color: #333;
		padding: 0 40rpx;
	}
	.mainSet-li+.mainSet-li{
		margin-top: 20rpx;
	}
	.mainSet-li text{
		color: #999;
	}
</style>
